package com.yupi.questionservice.controller.inner;



import com.yupi.ojsystemmodel.model.entity.Question;
import com.yupi.ojsystemmodel.model.entity.QuestionSubmit;
import com.yupi.questionservice.service.IQuestionService;
import com.yupi.questionservice.service.IQuestionSubmitService;
import com.yupi.serviceclient.service.QuestionFeignClient;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 该服务仅内部调用
 */
@RestController
@RequestMapping("/inner")
public class QuestionInnerController implements QuestionFeignClient {
    @Resource
    private IQuestionService questionService;
    @Resource
    private IQuestionSubmitService questionSubmitService;

    @GetMapping("/get/id")
    @Override
    public Question getQuestionById(@RequestParam("questionId") long questionId){
        return questionService.getById(questionId);
    }

    @GetMapping("/question_submit/get/id")
    @Override
    public QuestionSubmit getQuestionSubmitById(@RequestParam("questionSubmitId") long questionSubmitId){
        return questionSubmitService.getById(questionSubmitId);
    }

    @PostMapping("/question_submit/update")
    @Override
    public boolean updateQuestionSubmitById(@RequestBody QuestionSubmit questionSubmit){
        return questionSubmitService.updateById(questionSubmit);
    }

    @Override
    @PostMapping("/update")
    public boolean updateQuestionById(Question question) {
        return questionService.updateById(question);
    }

}